package com.exchange.used.repository;

import com.exchange.used.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface UserRepository extends JpaRepository<User, String> {

    User getUserByUsernameAndPassword(String username, String password);

    User getUserByUsername(String username);

    User getUserByUserid(String userid);


    @Query("update User set password=?2 where userid=?1")
    @Modifying(clearAutomatically = true)
    @Transactional
    void updateUserPassword(String userid, String password);

}
